//###############
// FILE : OpenDialogAction.java
// WRITER : Lior Zimmerman liorz06 066462300
// WRITER : Ohad Dan ohad_dan 036767960
// EXERCISE : oop ex3 2008
// DESCRIPTION:
// Checks if all parameters are fine for search.
//###############
package oop.ex3.fileSearchController;

import java.io.IOException;

import oop.ex3.fileSearchView.GUIView;
/**
 * Checks if all parameters are fine for search.
 */
public abstract class OpenDialogAction extends Controller {
    protected int _constraints;
    /**
     * Initialize a new open dialog handler.
     * @param gui Main frame
     * @param constraints directory\file only.
     */
    public OpenDialogAction(GUIView gui, int constraints) {
        super(gui);
        _constraints = constraints;
    }

   /**
    * Sets the data that was chosen by user at the tab.
    */
    public void doAction() {
        String path =_gui.getSearchView().txtWorkDirGetText();
        try{
            path = _gui.showOpenDialog(_constraints);
        }
        catch (IOException e){
            _gui.setStatus(e.getMessage());
        }
        setData(path);
    }
    public abstract void setData(String text);

}
